import java.util.LinkedList;

public class LeetCode101 {
    public boolean isSymmetric(TreeNode root) {
       return check(root.left,root.right);
    }
    public boolean check(TreeNode left,TreeNode right) {
        //当左右子树都为null时返回true
        if(left == null && right == null) {
            return true;
        }
        //其中一边不为null时返回null
        if(left == null || right == null) {
            return false;
        }
        //值不相等 false
        if(left.val != right.val) {
            return false;
        }
        //如果左右子树还有子节点 继续递归
        return check(left.left, right.right) && check(left.right, right.left);
    }
}
